#ifndef _LINKTREE_H_
#define _LINKTREE_H_
#define ElementType void*

class Node
{   
public:
    Node(ElementType element);
    Node *GetParent()const;
    ElementType GetData()const;
    void Connect(Node *parent); //将当前节点连接到parent节点上
    void DisConnect();
    
    static void TravelNode(Node *node,int depth,void(*showPtr)(ElementType));

    friend class LinkTree;
private:  
    ElementType data;  //结点的数据域
    Node *parent;   //父节点指针
    Node *nextSibling; //下一个兄弟节点
    Node *firstChild; //第一个孩子节点
    
};


class LinkTree
{
public:
    LinkTree();
    ~LinkTree();
    Node *GetRoot()const;

    int GetTreeHeight();
    Node* FindNode(ElementType element);
    void SetShowtype(void (*showPtr)(ElementType element));
    void SetFindType(bool(*IsEqual)(ElementType,ElementType));
    void show();
private:
    Node* FindNode(Node *node,ElementType element);
    void FreeNode(Node *node);
    int GetNodeHeight(Node *node);
    Node *root; //根节点
    void (*showPtr)(ElementType element);
    bool (*IsEqualPtr)(ElementType,ElementType);
};




#endif